This page last changed on Dec 10, 2008 by skim.
There are currently 3 ways to make a new OTClass. They are listed in order of preference. The first is the preferred way to make an OTClass.
- make an interface that extends the OTObjectInterface
- make a class that extends DefaultOTObject
- make a class that implements OTObject
Interface Extending OTObjectInterface
Make a new interface which extends OTObjectInterface. The properties of the OTClass are defined by defining get and set methods for those properties.
The OTrunk framework will dynamically create an implementation of this interface at runtime. You do not need to implement your interface
Class Extending DefaultOTObject
DefaultOTObject implements all of the methods of OTObject. The only thing you need to do is make an interface that extends OTResourceSchema and make a constructor for your class that takes a parameter whose type is this interfaces. You add properties to your OTClass by defining get and set methods for those properties. You do not need to implement your ResourceSchema interface, the OTrunk framework will dynamically create an implementation at runtime.
The difference between this approach and the Interface approach above is you can add behavior to your OTClass. But it also means if you want to provide access to the properties of your OTClass you need to write methods in the OTClass which delegate to the resource schema that was passed in the constructor.
Class Implementing OTObject
You need to create a resource schema interface like above, and you need to implement all the methods of OTObject.
This option should only be necessary if you want to turn an existing class into an OTObject. You can subclass it and implement the OTObject methods. There are alternative ways to link existing classes with OTObjects, particularly the OTView System and the OTController System. These alternative ways are preferred because they separate the data structure from the behavior.
- What does an OTClass do?
- Can you list a few examples?
- Can you sketch an example of adding a new class and what new functionality that adds to the system?
Posted by stepheneb at Apr 30, 2007 23:09
|
|